How to select a rectangle from List<Rectangle[]> with Linq

Posted by dboarman on Stack Overflow See other posts from Stack Overflow or by dboarman
Published on 2011-01-04T13:38:45Z Indexed on 2011/01/04 15:53 UTC
Read the original article Hit count: 378

Filed under:
|
|
|
|

I have a list of DrawObject[]. Each DrawObject has a Rectangle property. Here is my event:

List<Canvas.DrawObject[]> matrix;

void Control_MouseMove ( object sender, MouseEventArgs e )
{
    IEnumerable<Canvas.DrawObject> tile = Enumerable.Range( 0, matrix.Capacity - 1)
                                          .Where(row => Enumerable.Range(0, matrix[row].Length -1)
                                                 .Where(column => this[column, row].Rectangle.Contains(e.Location)))
                                          .????;
}

I am not sure exactly what my final select command should be in place of the "????". Also, I was getting an error: cannot convert IEnumerable to bool.

I've read several questions about performing a linq query on a list of arrays, but I can't quite get what is going wrong with this. Any help?

Edit Apologies for not being clear in my intentions with the implementation.

I intend to select the DrawObject that currently contains the mouse location.

© Stack Overflow or respective owner

Related posts about c#

Related posts about arrays